﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
	/// <summary>
	/// result from sql server full text search
	/// </summary>
	[Serializable]
	public class FullTextSearchResult : IComparable
	{
		private int _Rank;
		/// <summary></summary>
		public int Rank
		{
			get
			{
				return this._Rank;
			}
			set
			{
				this._Rank = value;
			}
		}

		private int _Key;
		/// <summary></summary>
		public int Key
		{
			get
			{
				return this._Key;
			}
			set
			{
				this._Key = value;
			}
		}

		private double _Score;
		/// <summary>
		/// OKAPI BM25 http://en.wikipedia.org/wiki/Probabilistic_relevance_model_(BM25)
		/// </summary>
		public double Score
		{
			get
			{
				return this._Score;
			}
			set
			{
				this._Score = value;
			}
		}

        private string _Title;
        /// <summary></summary>
        public string Title
        {
            get
            {
                return this._Title;
            }
            set
            {
                this._Title = value;
            }
        }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="rank"></param>
		/// <param name="key"></param>
		/// <param name="score"></param>
		/// <param name="title"></param>
		public FullTextSearchResult(int rank, int key, double score, string title)
		{
			this._Rank = rank;
			this._Key = key;
			this._Score = score;
		    this._Title = title;
		}

		#region Implementation of IComparable

		/// <summary>
		/// 
		/// </summary>
		/// <param name="obj"></param>
		/// <returns></returns>
		public int CompareTo(object obj)
		{
			if (obj.GetType() == this.GetType())
			{
				FullTextSearchResult otherResult = (FullTextSearchResult)obj;
				return otherResult.Score.CompareTo(this.Score);
			}
			else
				return 0;
		}

		#endregion
	}
}
